package org.darkforest.merchant.controller;

import org.darkforest.common.services.BrandService;
import org.darkforest.model.Brand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by Administrator on 2016/1/6.
 */
@RequestMapping(value = "brand")
@Controller
public class BrandController {
    @Autowired
    private BrandService brandService;

    @RequestMapping(value = "searchBrand")
    public @ResponseBody
    List<Brand> searchBrand(Integer type,String keyword){

        //用户输入关键词查询
        List<Brand> brands;
        Brand brand = new Brand();
        if(type==1){
            brand.setBrandName(keyword);
        } else {
            brand.setBrandInitial("all".equals(keyword) ? null : keyword);

        }

        brands = brandService.findBrandByCondition(brand);

        return brands;
    }

}
